#/usr/bin/env python

import os
import os.path
import shutil
import stat


def build(source_path, build_path, install_path, targets):
    def _install():
        src = os.path.join(source_path, 'src')
        dest = install_path

        if os.path.exists(install_path):
            shutil.rmtree(install_path)

        print(source_path)
        print(install_path)

        shutil.copytree(src, dest)

        # # Install commandline tools
        # srcScripts = os.path.join(source_path, 'bin')
        # dstScripts = os.path.join(install_path, 'bin')
        #
        # if os.path.exists(dstScripts):
        #     shutil.rmtree(dstScripts)
        # shutil.copytree(srcScripts, dstScripts)
        #
        # # binaries
        # mode = (stat.S_IRUSR | stat.S_IRGRP |
        #         stat.S_IXUSR | stat.S_IXGRP)
        #
        # for name in os.listdir(dstScripts):
        #     filePath = os.path.join(dstScripts, name)
        #     os.chmod(filePath, mode)

    if "install" in (targets or []):
        _install()
